<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class UserCurrentInfo extends MY_Controller {
	public function __construct(){
		parent::__construct();
		$this->isLogin();
		$this->load->model('UserCurrentInfo_model');
	}
	public function userCurrentInfoEdit(){
		if(isset($_POST['id'])){
			$data=$_POST;
	
			if(trim($data['name'])==''){
				ajax_return(0,'登陆名称不能为空');
			}
			if($data['pwd']!=$data['pwdok']){
				ajax_return(0,'两次密码设置不一样');
			}
			if($data['pwd']==''){//不修改密码
				unset($data['pwd']);
				unset($data['pwdok']);
			}else{
				$data['pwd']=userpassmd5($data['pwd']);
			}
			unset($data['pwdok']);
			if($this->UserCurrentInfo_model->pm_user_current_edit($data)===false){
				$keywords=$data['name']."账号,编辑失败";
				useraddrecord('用户编辑',$keywords);
				ajax_return(0,'提交失败');
			}else{
				$keywords=$data['name']."账号,编辑成功";
				useraddrecord('用户编辑',$keywords);
				ajax_return(1,'提交成功');
			}
		}else{
			//获取当前用户id
			$list=$this->UserCurrentInfo_model->pm_user_current_onelist($this->pmsuserinfo['id']);
			$this->assign('list',$list);
			$this->display('usercurrentinfo/useredit.html');
		}
	}
}
